﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link href="/Static/demo.css" rel="stylesheet" type="text/css" />
    <script src="/Static/boot.js" type="text/javascript"></script>
    <link href="/Static/miniui/themes/blue/skin.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div class="mini-toolbar" style="padding: 2px; border-bottom: 0;">
        <table style="width: 100%;">
            <tr>
                <td style="width: 90%;">
                    <label style="font-family: Verdana;">
                        品牌:
                    </label>
                    <input class="mini-textbox" id="txt_KeyValue" />
                    <label style="font-family: Verdana;">
                        是否启用:
                    </label>
                    <input name="IsActive" class="mini-combobox" textfield="text" valuefield="id" emptytext="请选择..."
                           value="" allowinput="false" shownullitem="true" url="/ConfigData/IsActive.txt" nullitemtext="请选择..." />

                    <a class="mini-button" iconcls="icon-search" onclick="searchList()">查询</a> <a class="mini-button"
                                                                                                  iconcls="icon-remove" onclick="clear()">清空条件</a>
                </td>
            </tr>
        </table>
    </div>
    <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
        <table style="width:100%;">
            <tr>
                <td style="width:100%;">
                    <a class="mini-button" iconcls="icon-add" onclick="AddBrand()" plain="true">增加</a>
                    <span class="separator"></span>
                    <a class="mini-button" iconcls="icon-edit" onclick="EditBrand()" plain="true">编辑</a>
                    <span class="separator"></span>
                    <a class="mini-button" iconcls="icon-remove" onclick="RemoveBrand()">删除</a>
                    <span class="separator"></span>
                    <a class="mini-button" iconcls="icon-reload" onclick="reloadData()" plain="true">刷新</a>
                </td>
            </tr>
        </table>
    </div>
    <div id="datagrid1" class="mini-datagrid" style="width: 100%; height: 88%;" url="/Ajax/AjaxService.aspx?method=GetPartsBrandList&sortField=IsAvailable&sordOrder=DESC" multiselect="true" onrowdblclick="EditBrand"
         idfield="ID" sizelist="[5,10,15,20,50]" pagesize="15">
        <div property="columns">
            <div type="checkcolumn" width="20">
            </div>
            <div type="indexcolumn" width="15">
            </div>
            <div field="BrandsName" width="50" headeralign="center" align="center" allowsort="true">
                品牌名称
            </div>
            <div field="BrandsDisplayName" width="100" headeralign="center" align="center" allowsort="true">
                显示名称
            </div>
            <div field="Remark" width="100" headeralign="center" align="center" allowsort="true">
                备注
            </div>
            <div field="IsAvailable" width="20" headeralign="center" align="center" allowsort="true">
                是否可用
            </div>
        </div>
    </div>
    <script type="text/javascript">
        mini.parse();
        var grid = mini.get("datagrid1");
        grid.sortBy("ID", "DESC");
        grid.load();

        //清空条件
        function clear() {
            mini.get("txt_KeyValue").setValue("");
            mini.getbyName("IsActive").setValue("");
        }
        //查询
        function searchList() {
            var keyValue = mini.get("txt_KeyValue").getValue();
            var isActive = mini.getbyName("IsActive").getValue();
            grid.load({ keyValue: keyValue, isActive: isActive });
        }
        function reloadData() {
            searchList();
        }
        $("#txt_KeyValue").bind("keydown", function (e) {
            if (e.keyCode == 13) {
                searchList();
            }
        });
        function RemoveBrand() {
            var rows = grid.getSelecteds();
            if (rows.length > 0) {
                if (confirm("确定删除选中记录？")) {
                    var ids = [];
                    for (var i = 0, l = rows.length; i < l; i++) {
                        var r = rows[i];
                        ids.push(r.ID);
                    }
                    var id = ids.join(',');
                    //alert(id);
                    grid.loading("操作中，请稍后......");
                    $.ajax({
                        url: "/Ajax/AjaxService.aspx?method=DeleteBrands",
                        data: {
                            ids: id
                        },
                        success: function (text) {
                            // mini.alert("操作成功!");
                            grid.reload();
                        },
                        error: function () {
                        }
                    });
                }
            } else {
                mini.alert("请选中一条记录");
            }
        }
        function EditBrand() {
            var row = grid.getSelected();
            if (row) {
                mini.open({
                    url: "/Parts/BrandEdit.html",
                    title: "编辑",
                    width: 900,
                    height: 550,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = { action: "Update", ID: row.ID };
                        iframe.contentWindow.SetData(data);
                    },
                    ondestroy: function (action) {
                        grid.reload();

                    }
                });

            } else {
                alert("请选中一条记录");
            }
        }
        /**新增*********************************************************************/
        function AddBrand() {
            mini.open({
                url: "/Parts/BrandEdit.html",
                title: "新增", width: 900, height: 550,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = { action: "Insert" };
                    iframe.contentWindow.SetData(data);
                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        }
    </script>
</body>
</html>
